package com.interview.ujiuye9;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

//api application program interface 应用程序编程接口，就是提供的一组类或接口 List
//阿里巴巴短信api，就是短信的接口，支付宝API，接口
public class Demo1 {
    Lock lock = new ReentrantLock();
    public  void add(){
        lock.lock();
        System.out.println("add=="+Thread.currentThread().getName());
        int num1  = 1;
        int num2 = 2;
        System.out.println(num1 + num2);
        subtract();
        lock.unlock();
    }

    public  void subtract(){
        lock.lock();
        System.out.println("subtract=="+Thread.currentThread().getName());
        int num1  = 1;
        int num2 = 2;
        System.out.println(num1 - num2);
        lock.unlock();
    }

    public static void main(String[] args) {
        new Demo1().add();
    }
}
